/*
 * ItemListIterator.java
 *
 */

package vendingMachine.gui;

import java.util.Iterator;
import java.util.ArrayList;

/**
 *
 * @author Mike
 */
public class ItemListIterator implements Iterator {
    
    ArrayList itemList;
    int position = 0; 
    
    /**
     * Creates a new instance of ItemListIterator
     */
    public ItemListIterator(ArrayList items) {
            this.itemList = items;
         }

    public Object next() {
            Object object = itemList.get(position);
            position = position + 1;
            return object;
    }

    public boolean hasNext() {
            if (position >= itemList.size()) {
                    return false;
            } else {
                    return true;
            }
    } 
    
    public void remove() {
            throw new UnsupportedOperationException(
            "Item List Iterator does not support remove()");
    }

}
